public class 复利计算 {
    public static void main(String[] args) {
        System.out.println(calc(100, 0.205, 2000));
    }

    //计算需要多少年本金达到目标金额
    static int calc(double raw_money,double rate,double wish_money){
        int year = 0;
        while (raw_money<wish_money){
            year++;
            raw_money = raw_money*(1+rate);
        }
        return year;
    }
}
